home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14094 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.3 KB

  1. Path: kai.com!not-for-mail
  2. From: robison@kai.com (Arch Robison)
  3. Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
  4. Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
  5. Date: 28 Mar 1996 10:39:09 -0600
  6. Organization: Kuck & Associates, Inc.
  7. Message-ID: <4jefbd$k33@kai.com>
  8. References: <4j954n$mrq@kai.com> <1996Mar27.211117.5569@schbbs.mot.com>
  9. NNTP-Posting-Host: kai.com
  10.  
  11. In article <1996Mar27.211117.5569@schbbs.mot.com> shang@corp.mot.com writes:
  12. >If resumption semantics were inferior, why should we bother to get
  13. >its "benefits" by simulating its semantics as below:
  14.  
  15. I should have qualified my statement "inferior" to "inferior in most cases".
  16.  
  17. >>     bool retry;
  18. >>     do {
  19. >>     retry = false;
  20. >>     try {
  21. >>         result = do_something();
  22. >>     }
  23. >>     catch( condition1 ) {some_extraordinary_work1();  retry=true;}
  24. >>     catch( condition2 ) {some_extraordinary_work2();  retry=true;}
  25. >>     catch( condition3 ) {some_extraordinary_work3();  retry=true;}
  26. >>         catch( condition4 ) {result=NULL;}
  27. >>     } while( retry );
  28. >> 
  29. >
  30. >How do you define these conditions? They must be in different types,
  31. >I assume, otherwise C++ cannot locate the cather.
  32. >
  33. >What happen if we forget to inialize "retry"? Okay, we can use break, but
  34. >what happen if we have nested exceptions? "Goto" must be used, I guess.
  35. >Busy jumps around are no fun.
  36. >
  37. >What happen if we forget to set "result" to NULL under condition4?
  38.  
  39. What if I forget to increment my loop variables?  What if I use single 
  40. precision where I should have used double precision?  What if I misunderstood 
  41. the problem specification?  What if my disk drive explodes today?
  42. For any programming problem X, I can build a complete solution to X
  43. into the language (or hardware).  FORTRAN solves the loop problem
  44. with a do-loop form.  Infinite-precision arithmetic solves problems too, 
  45. but at run-time cost.  Endless meetings and documents (according to some 
  46. theories) solve specification problems.  And I can encase my machine in a 
  47. steel case to protect me from explosions.  But sometimes I judge that the 
  48. cost of doing so is not worth the likely benefit.  
  49.  
  50. The original attack on C++ unfairly implied that the C++ committee had given no
  51. though to the issues.  As described in Stroustrup's D&E book, the C++ committee 
  52. knowledgeably debated the resumption vs. termination models of exception 
  53. handling and judged that the extra cost of the resumption model was not worth 
  54. the cost in added complexity.  There is no such thing as a feature
  55. that "you do not pay for it if you do not use it."  Each feature that is
  56. implemented subtracts time from implementing or refining other features.
  57. I am employed implementing the optimizer for a high-performance C++ compiler, 
  58. so I speak from experience.  
  59.  
  60. Thus many apparently useful features are deliberately left out of C++ .
  61. Users who want the features can simulate them without burdening others.
  62. Besides, for some of these features, even the users who want them
  63. disagree about the precise semantics, so it is often better to let
  64. the users simulate the feature so that they can define the semantics they want.
  65.  
  66. C++ is not intended to be the best language for all problems.
  67. If another language is better for your problem, use it.
  68.  
  69. Arch D. Robison                Kuck & Associates Inc.
  70. robison@kai.com             1906 Fox Drive
  71. 217-356-2288                   Champaign IL 61820
  72.